home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_ONEDBF.TXT < prev    next >
Encoding:
Text File  |  1992-12-22  |  10.7 KB  |  284 lines

  1. '
  2. 'Class structure:
  3. '
  4. !short:OneDbf class structure:
  5. Class  OneDbf:
  6. ~~~~~~~~~~~~~~
  7. Includes the high level maintenance of one workarea, i.e. one database file
  8. and its index files. The information about this file relations is stored
  9. here.
  10.  
  11. Common use:
  12. ~~~~~~~~~~~
  13. The kernel for the Dbf class, for servicing of the database files, can be
  14. used separate but it is no need for such use, when yes so in the following
  15. way:
  16. LOCAL OBJECT Od OF OneDbf INIT
  17. Od:AddField(...) //ƒø
  18. Od:Picture(..)   // ≥one database field description
  19. Od:When(..)      // ≥these four rows can be repeated
  20. Od:Valid(..)     //ƒŸ
  21. ...
  22. Od:AddNtx(...)   //index file definition added
  23. ...
  24. Od:Create()      //new database and its index files created
  25. ...
  26.  
  27. Source code is in C_Dbf.prg
  28.  
  29. !seealso: c_dbf.ngo:Dbf c_color.ngo:Color ob_class.ngo:"Class hierarchy"
  30.  
  31. !short:~~~~~~~~~~~~~~~~~~~~~~~
  32. !short:create class OneDbf
  33. !short:  export:
  34. !short:  var File       //""
  35. ^BOneDbf:File^N: public: character
  36.   Database file name, can be set as full name including the drive and path.
  37.  
  38. !short:  var Name       //""
  39. ^BOneDbf:Name^N: public: character
  40.   Alias database name.
  41.  
  42. !short:  var Struc      //{}
  43. ^BOneDbf:Struc^N: read-only: array
  44.   Database structure (the structure of the fields) is stored here
  45.   Struc:={}
  46.   AAdd( Struc, {cFieldName,cFieldType,nLen,nDec} )
  47.   ...
  48.   Where:
  49.   cFieldName - is the fieldname
  50.   cFieldType - can be "C","M","N","D","L"
  51.   nLen       - field size in number of characters
  52.   nDec       - number of decimal places of type "N", or type "C" size
  53.                extension in 256 multiples (see clipper manuals)
  54.   The structure of the array Struc is the same as the aStruc in clipper
  55.   function DBCREATE().
  56.  
  57. !short:  var Pict       //{}
  58. ^BOneDbf:Pict^N: read-only: array
  59.   Onedimensional paralel array to instvar variable Struc, for storing of the
  60.   picture mask of each filed.
  61.  
  62. !short:  var PreBlock   //{}
  63. ^BOneDbf:PreBlock^N: read-only: array
  64.   Onedimensional paralel array to instvar variable Struc, for storing of the
  65.   prevalid code block (PreBlock) for each field.
  66.  
  67. !short:  var PostBlock  //{}
  68. ^BOneDbf:PostBlock^N: read-only: array
  69.   Onedimensional paralel array to instavr variable Struc, for storing of the
  70.   post valid code block (PostBlock) for each field.
  71.  
  72. !short:  var Ntx        //{}
  73. ^BOneDbf:Ntx^N: read-only: array
  74.   Index file definition in form of:
  75.   Ntx:={}
  76.   AAdd( Ntx, {cMenuName,cFileName,cKey,lUnique,lUserDefined} )
  77.   ...
  78.   Where:
  79.   cMenuName    - menu item name, for enabling the selection of this index
  80.                  file with SET ORDER TO
  81.   cFileName    - is the index file name
  82.   cKey         - is the key expression for this index file
  83.   lUnique      - sets the index to be unique or no
  84.   lUserDefined - sets the index to be user defined when runing the program
  85.                  or no. (its flag is only for internal library use,
  86.                  you can use it only in read-only mode)
  87.  
  88. !short:  var Rel        //{}
  89. ^BOneDbf:Rel^N: read-only: array
  90.   Databese file relations decscription:
  91.   Rel:={}
  92.   AAdd( Rel, {cKey,cAlias,nOrder} )
  93.   ...
  94.   Where:
  95.   cKey   - is the key expression as text string, when databases are
  96.            connected it is SEEK command after this expression executed
  97.   cAlias - is the workarea for SEEK
  98.   nOrder - active index order in active ALIAS workarea
  99.  
  100. !short:  method New=OneDbfNew                 //o:New() --> self
  101. ^BOneDbf:New()^N: public: return self
  102.   The object is filled with default values.
  103.  
  104. !short:  method Init=OneDbfInit               //o:Init() --> true
  105. ^BOneDbf:Init()^N: public: return true
  106.   Returns true, no other action.
  107.  
  108. !short:  method Create=OneDbfCreate           //o:Create(lContinue) --> true/false
  109. ^BOneDbf:Create(lContinue)^N: public: return true/false
  110.   The empty database file is created (if exists it is recreated) with its
  111.   index files. When succesfull returns true.
  112.  
  113.   Parameter description:
  114.   ~~~~~~~~~~~~~~~~~~~~~~
  115.   ^UlContinue^N: logical: default is true
  116.    If true, it can be continuing the program even if the files couldn't be
  117.    created. This must be confirmed by the user. This problem may arise in
  118.    the network environment. The databases are opened shared when the
  119.    programmer dont set other way as default.
  120.  
  121. !short:  method Open=OneDbfOpen               //o:Open(lShared,lContinue,lNew) --> true/false
  122. ^BOneDbf:Open(lShared,lContinue,lNew)^N: public: return true/false
  123.   The databese is opened with its index files in the network environment.
  124.   When succesfull returns true.
  125.  
  126.   Parameter description:
  127.   ~~~~~~~~~~~~~~~~~~~~~~
  128.   ^UlShared^N: logical: default is true
  129.    Default for shared database files opening in network environment.
  130.  
  131.   ^UlContinue^N: logical: default is true
  132.    If true, it can be continuing the program even if the files couldn't
  133.    be opened. This must be confirmed by the user.
  134.    This problem may arise in the network environment.
  135.  
  136.   ^UlNew^N: logical: default is true
  137.    If true the database is opened in the first empty workarea,
  138.    otherwise it is opened in the active workarea.
  139.  
  140. !short:  method NtxOpen=OneDbfNtxOpen         //o:NtxOpen(lContinue) --> true/false
  141. ^BOneDbf:NtxOpen(lContinue)^N: public: return true/false
  142.   The index files of opened database file are opened (as by the command
  143.   NET SET INDEX). When succesfull returns true.
  144.  
  145.   Parameters descripton:
  146.   ~~~~~~~~~~~~~~~~~~~~~~
  147.   ^UlContinue^N: logical: default is true
  148.    If true, it can be continuing the program even if the files couldn't be
  149.    opened. This must be confirmed by the user.
  150.    This problem may arise in the network environment.
  151.  
  152. !short:  method ReIndex=OneDbfReIndex         //o:ReIndex(lContinue) --> true/false
  153. ^BOneDbf:ReIndex(lContinue)^N: public: return true/false
  154.   The index files to opened database file are created, if exist they are
  155.   recreated (as in ther command NET INDEX ON).
  156.   When succesfull returns true.
  157.  
  158.   Parameters description:
  159.   ~~~~~~~~~~~~~~~~~~~~~~~
  160.   ^UlContinue^N: logical: default is true
  161.    If true it can be continued in the program even if the required files
  162.    couldn't be created. The continuing in a program must be confirmed by
  163.    the user, this problem may arise in network environment.
  164.  
  165. !short:  method Pack=OneDbfPack               //o:Pack(lContinue) --> true/false
  166. ^BOneDbf:Pack(lContinue)^N: public: return true/false
  167.   The PACK command is performed for this database file in network
  168.   environment. If succesfull it returns true.
  169.  
  170.   Parameter description:
  171.   ~~~~~~~~~~~~~~~~~~~~~~
  172.   ^UlContinue^N: logical: default is true
  173.    If true it can be continued in the program even if the required files
  174.    couldn't be created. The continuing in a program must be confirmed
  175.    by the user, this problen may arise in network environment.
  176.  
  177. !short:  method Zap=OneDbfZap                 //o:Zap(lContinue) --> true/false
  178. ^BOneDbf:Zap(lContinue)^N: public: return true/false
  179.   The same as in the Pack but instead of is the ZAP command performed.
  180.  
  181. !short:  method SetRelation=OneDbfSetRelation //o:SetRelation() --> true
  182. ^BOneDbf:SetRelation()^N: public: return true
  183.   If all databases are opened the relations for this database can be build.
  184.  
  185. !short:  method AddField=OneDbfAddField       //o:AddField(cName,cType,nLen,nDec) --> true
  186. ^BOneDbf:AddField(cName,cType,nLen,nDec)^N: public: return true
  187.   When creating the database structure, the next field can be appended
  188.   to the structure.
  189.  
  190.   Parameter description:
  191.   ~~~~~~~~~~~~~~~~~~~~~~
  192.   ^UcName^N: character: no default
  193.    database filed name
  194.  
  195.   ^UcType^N: character: no default
  196.    Field type, can be "C","M","N","D" or "L"
  197.  
  198.   ^UnLen^N: numeric: default is 10,8 or 10 (after field type)
  199.  
  200.   ^UnDec^N: numeric: default is 0
  201.    Number of decimal places for type "N" or adding of length of field type
  202.    "C" in 256 multiples. See original clipper manuals.
  203.  
  204. !short:  method AddNtx=OneDbfAddNtx           //o:AddNtx(cName,cFile,cKey,lUnique,lUser) --> true
  205. ^BOneDbf:AddNtx(cName,cFile,cKey,lUnique,lUser)^N: public: return true
  206.   Index definition for this database is added.
  207.  
  208.   Parameter description:
  209.   ~~~~~~~~~~~~~~~~~~~~~~
  210.   ^UcName^N: character: no default
  211.    Menu item name for activating of this index file (SET ORDER).
  212.  
  213.   ^UcFile^N: character: no default
  214.    Index file name.
  215.  
  216.   ^UcKey^N: character: no default
  217.    Key expression for this index file.
  218.  
  219.   ^UlUnique^N: logical: default is false
  220.    Sets the index to be "unique".
  221.  
  222.   ^UlUser^N: logical: default is false
  223.    Sets the index to be user created when running the program.
  224.  
  225. !short:  method AddRelation=OneDbfAddRelation //o:AddRelation(xKey,cAlias,nOrder) --> true
  226. ^BOneDbf:AddRelation(cKey,cAlias,nOrder)^N: public: return true
  227.   One relation definition is appended to this database.
  228.  
  229.   Parameter description:
  230.   ~~~~~~~~~~~~~~~~~~~~~~
  231.   ^UcKey^N: character: no default
  232.    The key expression in a form of text string, when connecting the databases
  233.    the SEEK command after this evaluated expression is performed.
  234.  
  235.   ^UcAlias^N: character: no default
  236.    The alias workarea for seek command.
  237.  
  238.   ^UnOrder^N: numeric: no default
  239.    The active  index file order in cAlias workarea.
  240.  
  241. !short:  method Picture=OneDbfPicture         //o:Picture(cPict) --> true
  242. ^BOneDbf:Picture(cPict)^N: public: return true
  243.   The last defined database field is appended with the input picture mask.
  244.  
  245.   Parameter description:
  246.   ~~~~~~~~~~~~~~~~~~~~~~
  247.   ^UcPict^N: character: no default
  248.    The input picture mask.
  249.  
  250. !short:  method Range=OneDbfRange             //o:Range(nLo,nHi) --> true
  251. ^BOneDbf:Range(nLo,nHi)^N: public: return true
  252.   For last created field is Valid code block created for testing the range
  253.   of edited value.
  254.  
  255.   Parameter description:
  256.   ~~~~~~~~~~~~~~~~~~~~~~
  257.   ^UnLo^N: numeric: no default
  258.    Low range limit.
  259.  
  260.   ^UnHi^N: numeric: no default
  261.    High range limit.
  262.  
  263. !short:  method When=OneDbfWhen               //o:When(bWhen) --> true
  264. ^BOneDbf:When(bWhen)^N: public: return true
  265.   For last created field is When code block created, which is performed
  266.   before entering the field editation. When returns false, the field
  267.   editation is skipped.
  268.  
  269. !short:  method Valid=OneDbfValid             //o:Valid(bValid) --> true
  270. ^BOneDbf:Valid(bValid)^N: public: return true
  271.   For last created field is Valid code block created, which is performed
  272.   when finishing the field editation. When returns false, the field
  273.   editation finishing is supressed (you must continue to correct the value).
  274.  
  275. !short:  method ChValid=OneDbfChValid         //o:ChValid(bValid) --> true
  276. ^BOneDbf:ChValid(bValid)^N: public: return true
  277.   For last created field is Valid code block created, which is performed
  278.   when finishing the field editation AFTER its value change. When returns
  279.   false, the field editation finishing is supressed (you must continue to
  280.   correct the value).
  281.  
  282. !short:  endclass
  283.  
  284.